package com.zhuangjie.rider.feign;

import com.zhaungjie.base.conduit.TypeR;
import com.zhuangjie.order.dto.RiderLocationUpdateDTO;
import com.zhuangjie.order.pojo.DeliveryInfoForRider;
import com.zhuangjie.order.vo.OrderDetailForDeliveryOrderDetailVO;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;

@Component
@FeignClient(name = "spark-order", path = "/order")
public interface OrderFeignService {
    @GetMapping("/delivery-info/query-for-create-delivery-order/{orderId}")
    TypeR<DeliveryInfoForRider> queryForCreateDeliveryOrder(@PathVariable("orderId") Long orderId);

    @GetMapping("/order/order-detail-for-delivery-order-detail")
    TypeR<OrderDetailForDeliveryOrderDetailVO> orderDetailForDeliveryOrderDetail(@NotNull(message = "订单id不能为空") @RequestParam("orderId") Long orderId);

    @PutMapping("/order/{orderId}/delivering")
    TypeR<Void> updateDeliveryOrderToDelivering(@PathVariable("orderId") Long orderId);

    @PutMapping("/order/{orderId}/completed")
    TypeR<Void> updateDeliveryOrderToCompleted( @PathVariable("orderId") Long orderId);


    @PutMapping("/sse/user/order-state-change")
    @ApiOperation("提醒用户端，订单状态已经改变")
    TypeR<Void> orderStateChange(@RequestParam(value = "userId", required = false) Long userId,@RequestParam("orderId") Long orderId);


    @PutMapping("/sse/user/rider-location-update")
    @ApiOperation("骑手位置更新")
    TypeR<Void> riderLocationUpdate(@Valid @RequestBody RiderLocationUpdateDTO riderLocationUpdateDTO);
}

